package dempClone;

public class Person implements Cloneable{
    public int id;
    public Money money=new Money();
    public Person(int id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
       //浅拷贝；
         //return super.clone();
        // 深拷贝；
        Person tmp=(Person) super.clone();
        tmp.money=(Money) this.money.clone();
        return tmp;
    }
}
